package Search;

import java.sql.*;
import java.util.ArrayList;
import java.util.Optional;

public class SearchCommonSentence {
    String url = "jdbc:mysql://127.0.0.1:3306/nox?useUnicode=true&characterEncoding=UTF-8&userSSL=false&serverTimezone=GMT%2B8";
    String user = "root";
    String password = "Mi20030610.";
    public ArrayList<String> search(String id) throws ClassNotFoundException, SQLException {
        ArrayList<String> sentenceList=new ArrayList<>();
        String sql="select *from common_sentence_list where userid=?;";
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection Conn = DriverManager.getConnection(url, user, password);

        PreparedStatement operation=Conn.prepareStatement(sql);
        operation.setString(1,id);

        ResultSet resultSet=operation.executeQuery();
        while(resultSet.next())
        {
            sentenceList.add(resultSet.getString("sentence"));
        }
        return sentenceList;
    }
}
